package com.wxl.common.util

import java.text.SimpleDateFormat
import java.util.*

/**
 * create file time : 2021/3/8
 * create user : wxl
 * subscribe :
 */
class DateUtils {
    companion object {
        val HMS = SimpleDateFormat("HH:mm:ss")
        val YMD = SimpleDateFormat("yyyy:MM:dd")

        fun getHMS(): String {
            return HMS.format(Date())
        }

        fun getYMD(): String {
            return YMD.format(Date())
        }

        fun getYMDWeek() : String{
            val calendar = Calendar.getInstance()
            calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"))
            val mYear = calendar.get(Calendar.YEAR) // 获取当前年份
            val mMonth = calendar.get(Calendar.MONTH) + 1// 获取当前月份
            val mDay = calendar.get(Calendar.DAY_OF_MONTH)// 获取当前月份的日期号码
            var mWay : String = calendar.get(Calendar.DAY_OF_WEEK).toString()
            when {
                "1".equals(mWay) -> {
                    mWay ="天"
                }
                "2".equals(mWay) -> {
                    mWay ="一"
                }
                "3".equals(mWay) -> {
                    mWay ="二"
                }
                "4".equals(mWay) -> {
                    mWay ="三"
                }
                "5".equals(mWay) -> {
                    mWay ="四"
                }
                "6".equals(mWay) -> {
                    mWay ="五"
                }
                "7".equals(mWay) -> {
                    mWay ="六"
                }
            }
            return "$mYear 年 $mMonth 月 $mDay 日  星期 $mWay"
        }
    }
}